package com.jspgou.cms.action.front;

import static com.jspgou.cms.Constants.COMMON_SYS;
import static com.jspgou.cms.Constants.MEMBER_SYS;
import static com.jspgou.common.web.Constants.MESSAGE;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.jdom.JDOMException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jspgou.common.web.RequestUtils;
import com.jspgou.common.web.springmvc.MessageResolver;
import com.jspgou.core.entity.Website;
import com.jspgou.core.web.front.FrontHelper;
import com.jspgou.cms.Alipay;
import com.jspgou.cms.entity.Shipments;
import com.jspgou.cms.entity.ShopAdmin;
import com.jspgou.cms.entity.ShopPaymentorder;
import com.jspgou.cms.entity.ShopYushou;
import com.jspgou.cms.entity.Order;
import com.jspgou.cms.entity.Payment;
import com.jspgou.cms.manager.ShipmentsMng;
import com.jspgou.cms.manager.ShopPaymentorderMng;
import com.jspgou.cms.manager.ShopYushouMng;
import com.jspgou.cms.manager.OrderMng;
import com.jspgou.cms.manager.PaymentMng;
import com.jspgou.cms.web.ShopFrontHelper;
import com.jspgou.cms.web.SiteUtils;
import com.jspgou.cms.web.threadvariable.AdminThread;

/**
 * 支付宝担保交易支付和即时支付接口，（即时支付接口暂时都不太确定是否能支付成功）
* This class should preserve.
* @preserve
*/
@Controller
public class AlipayAct extends Alipay {
	/**
	 * 前台发货
	 * @param trade_no 支付宝交易号
	 * @param bean
	 * @param id
	 * @param request
	 * @param invoiceNo 物流发货单号   
	 * @param freight 运费
	 * @param response
	 * @param model
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value="/orderSt/o_sendGoods.jspx",method=RequestMethod.POST)
	public String shipments(String trade_no,Shipments bean,Long id, HttpServletRequest request,
			String invoiceNo,Double freight,HttpServletResponse 
			response, ModelMap model) {
		Order order=manager.findByTradeNo(trade_no);
		if(order==null){
			order=manager.findById(id);
		}
		ShopAdmin admin = AdminThread.get();
		bean.setShopAdmin(admin);
		bean.setIndent(order);
		order.setInvoiceNo(invoiceNo);
		Double total=order.getTotal();
		if(order.getFreight()!=null){
			total=total-order.getFreight();
		}
		order.setFreight(freight);
		total+=freight;
		order.setTotal(total);
		if(order.getPayment().getId()==2){
			//配送方式为未配送，状态为已确认，支付状态为已支付
			if(order.getShippingStatus()==1&&order.getStatus()==2&&order.getPaymentStatus()==2){
				order.setShippingStatus(2);
				shipmentMng.save(bean);
				manager.updateByUpdater(order);
				if(order.getPayment()!=null){
		        	if(order.getPayment().getCode().equals("alipayPartner")){
		        		try {
							alipay(order.getPayment(),order,invoiceNo);
						} catch (Exception e) {
							e.printStackTrace();
						} 		
		        	}
		        }
			}
		}
		model.addAttribute("order", order);
		return "redirect:deliverList.jspx";
	}	
	
	//本地测试
//	@RequestMapping(value="/ordersPay.jspx",method=RequestMethod.POST)
//	public String ordersPay(Long orderId,String code,HttpServletRequest request,HttpServletResponse response, ModelMap model){
//		Website web = SiteUtils.getWeb(request);		
//		if(orderId!=null&&shopPermentOrderMng.findById(orderId)!=null){
//			ShopPaymentorder shopPermentorder=shopPermentOrderMng.findById(orderId);
//			Payment payment=paymentMng.findByCode(code);			
//		    PrintWriter out=null;
//			String aliURL=null;			
//			
//				if(!StringUtils.isBlank(code)&&code.equals("alipayPartner")){
//					shopPermentorder.setStatus(2);
//					//shopPermentorder.setTradeno(trade_no);
//					shopPermentOrderMng.update(shopPermentorder);
//					List<Order> order= manager.getPaymentOrder(shopPermentorder);
//					for(int i=0;i<order.size();i++){
//						//副订单改成“已支付”
//						order.get(i).setPaymentStatus(2);
//						//order.get(i).setTradeNo(trade_no);
//						order.get(i).setPaymentCode("alipayPartner");
//						manager.updateByUpdater(order.get(i));
//					}
//					return  ShopFrontHelper.showMessage(request, model,"交易完成！");
//				} else if(!StringUtils.isBlank(code)&&code.equals("alipay")){
//					aliURL=ordersPayalipayapi(payment,web,shopPermentorder,request,model);
//				}
//		}else {
//		return FrontHelper.pageNotFound(web, model, request);	
//		}
//		return null;
//	}	
	
	//在线支付订单(多个订单提交付款时{加入购物车的形式最终付款})
	@RequestMapping(value="/ordersPay.jspx",method=RequestMethod.POST)
	public String ordersPay(Long orderId,String code,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws JDOMException{
		Website web = SiteUtils.getWeb(request);		
		if(orderId!=null&&shopPermentOrderMng.findById(orderId)!=null){
			ShopPaymentorder shopPermentorder=shopPermentOrderMng.findById(orderId);
			Payment payment=paymentMng.findByCode(code);			
		    PrintWriter out=null;
			String aliURL=null;			
			try{
				if(!StringUtils.isBlank(code)&&code.equals("alipayPartner")){
					aliURL=ordersPayalipay(payment,web,shopPermentorder,request,model);
					
				} else if(!StringUtils.isBlank(code)&&code.equals("alipay")){
					aliURL=ordersPayalipayapi(payment,web,shopPermentorder,request,model);		
				}
				response.setContentType("text/html;charset=UTF-8");
				out=response.getWriter();
				out.print(aliURL);
			}catch(IOException e){
				e.printStackTrace();
			}finally{					
				out.close();			
			}
			return null;
		}else {
			return FrontHelper.pageNotFound(web, model, request);
	   }				
	}	

	//在线支付订单({立即购买的形式最终付款})
	@RequestMapping(value="/pay.jspx",method=RequestMethod.POST)
	public String pay(Long orderId,String code,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws JDOMException{
		Website web = SiteUtils.getWeb(request);		
		if(orderId!=null&&manager.findById(orderId)!=null){
			Order order=manager.findById(orderId);
			Payment payment=paymentMng.findByCode(code);			
		    PrintWriter out=null;
			String aliURL=null;			
			try{
				if(!StringUtils.isBlank(code)&&code.equals("alipayPartner")){
					aliURL=alipay(payment,web,order,request,model);
					
				} else if(!StringUtils.isBlank(code)&&code.equals("alipay")){
					aliURL=alipayapi(payment,web,order,request,model);
					
				}else if(!StringUtils.isBlank(code)&&code.equals("weChatScancodePay")){
					aliURL=WeChatScanCodePay(payment,web,order,request,response, model);
				}
				response.setContentType("text/html;charset=UTF-8");
				out=response.getWriter();
				out.print(aliURL);
			}catch(IOException e){
				e.printStackTrace();
			}finally{
				out.close();
			}
			return null;
		}else {
		return FrontHelper.pageNotFound(web, model, request);
	   }		
		
	}	
	
	/**
	 * 
	 * @param orderId 预售订单id
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	//在线支付订单({商品预付的形式最终付款})
	@RequestMapping(value="/payYushou.jspx",method=RequestMethod.POST)
	public String payYushou(Long orderId,HttpServletRequest request,HttpServletResponse response, ModelMap model){
		Website web = SiteUtils.getWeb(request);
		if(orderId!=null&&yushouMng.findById(orderId)!=null){
			ShopYushou yushouorder=yushouMng.findById(orderId);
			Payment payment = yushouorder.getPay();
			PrintWriter out = null;
			String aliURL = null;
			try {
				if(payment.getCode().equals("alipayPartner")){
					aliURL = alipayYushou(payment,web, yushouorder, request, model);		
				}else if(payment.getCode().equals("alipay")){
					aliURL = alipayapiYushou(payment,web, yushouorder, request, model);
				}
				response.setContentType("text/html;charset=UTF-8");
				out = response.getWriter();
				out.print(aliURL);    
			} catch (IOException e) {
				e.printStackTrace();
			}finally{
				out.close();
			}
			return null;	
		}else {
			return FrontHelper.pageNotFound(web, model, request);
		}		
	}

	/**
	 * 预售尾款支付
	 * @param yushouId 预售订单id
	 * @param code 支付方式code
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/yuShouWkpay.jspx",method=RequestMethod.POST)
	public String yuShouWkpay(Long yushouId,String code,HttpServletRequest request,HttpServletResponse response, ModelMap model){
		Website web = SiteUtils.getWeb(request);		
		if(yushouId!=null&&yushouMng.findById(yushouId)!=null){
			ShopYushou yushou=yushouMng.findById(yushouId);
			Payment payment=paymentMng.findByCode(code);			
		    PrintWriter out=null;
			String aliURL=null;			
			try{
				if(!StringUtils.isBlank(code)&&code.equals("alipayPartner")){
					aliURL=alipayYushouWk(payment,web,yushou,request,model);
					
				} else if(!StringUtils.isBlank(code)&&code.equals("alipay")){
					aliURL=alipayapiYushouWk(payment,web,yushou,request,model);
				}
				response.setContentType("text/html;charset=UTF-8");
				out=response.getWriter();
				out.print(aliURL);
			}catch(IOException e){
				e.printStackTrace();
			}finally{
				out.close();
			}
			return null;
		}else {
		return FrontHelper.pageNotFound(web, model, request);
	   }		
	}
	
	//支付宝返回参数:多个订单提交付款时{加入购物车的形式最终付款})
	@RequestMapping(value = "/ordersPayaliReturn.jspx")
	public String ordersPayaliReturn(Long id,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]: valueStr + values[i] + ",";
			}
			params.put(name, valueStr);
		}
		//商户订单号
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
		Payment payment =paymentMng.findByCode("alipayPartner");
		//Long Id1=Long.parseLong(out_trade_no);
		ShopPaymentorder shopPermentorder=shopPermentOrderMng.findByCode(out_trade_no);
		if(verify(params,payment.getPartner(),payment.getSellerKey())){
			if(trade_status.equals("WAIT_BUYER_PAY")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录，但没有付款
				return ShopFrontHelper.showMessage(request, model, "付款失败!");
			}else if(trade_status.equals("WAIT_SELLER_SEND_GOODS")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功，但卖家没有发货
				//主订单改成“已支付”
				shopPermentorder.setStatus(2);
				shopPermentorder.setTradeno(trade_no);
				shopPermentOrderMng.update(shopPermentorder);
				List<Order> order= manager.getPaymentOrder(shopPermentorder);
				for(int i=0;i<order.size();i++){
					//副订单改成“已支付”
					order.get(i).setPaymentStatus(2);
					order.get(i).setTradeNo(trade_no);
					order.get(i).setPaymentCode("alipayPartner");
					manager.updateByUpdater(order.get(i));
				}
				return  ShopFrontHelper.showMessage(request, model,"success");
			}else if(trade_status.equals("WAIT_BUYER_CONFIRM_GOODS")){
				//该判断表示卖家已经发了货，但买家还没有做确认收货的操作
				return  ShopFrontHelper.showMessage(request, model,"已发货，未确认收货！");
			}else if(trade_status.equals("TRADE_FINISHED")){
				//该判断表示买家已经确认收货，这笔交易完成
				return  ShopFrontHelper.showMessage(request, model,"交易完成！");
			}else {
				return  ShopFrontHelper.showMessage(request, model,"success");
			}
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	//支付宝返回参数
	@RequestMapping(value = "/aliReturn.jspx")
	public String aliReturn(Long id,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]: valueStr + values[i] + ",";
			}
			params.put(name, valueStr);
		}
		//商户订单号
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
		Payment payment =paymentMng.findByCode("alipayPartner");
		//Long Id1=Long.parseLong(out_trade_no);
		Order order=manager.findByCode(out_trade_no);
		if(verify(params,payment.getPartner(),payment.getSellerKey())){
			if(trade_status.equals("WAIT_BUYER_PAY")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录，但没有付款
				return ShopFrontHelper.showMessage(request, model, "付款失败!");
			}else if(trade_status.equals("WAIT_SELLER_SEND_GOODS")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功，但卖家没有发货
				order.setPaymentStatus(2);
				order.setTradeNo(trade_no);
				order.setPaymentCode("alipayPartner");
				manager.updateByUpdater(order);
				return  ShopFrontHelper.showMessage(request, model,"success");
			}else if(trade_status.equals("WAIT_BUYER_CONFIRM_GOODS")){
				//该判断表示卖家已经发了货，但买家还没有做确认收货的操作
				return  ShopFrontHelper.showMessage(request, model,"已发货，未确认收货！");
			}else if(trade_status.equals("TRADE_FINISHED")){
				//该判断表示买家已经确认收货，这笔交易完成
				return  ShopFrontHelper.showMessage(request, model,"交易完成！");
			}else {
				return  ShopFrontHelper.showMessage(request, model,"success");
			}
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	/**
	 * 预售支付宝返回参数
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "/aliReturnYushou.jspx")
	public String aliReturnYushou(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]: valueStr + values[i] + ",";
			}
			params.put(name, valueStr);
		}
		//商户预售订单id
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
		Payment payment =paymentMng.findByCode("alipayPartner");
		ShopYushou yushouorder=yushouMng.findByCode(out_trade_no);
		if(verify(params,payment.getPartner(),payment.getSellerKey())){
			if(trade_status.equals("WAIT_BUYER_PAY")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录，但没有付款
				return  ShopFrontHelper.showMessage(request, model,"付款失败！");
			}else if(trade_status.equals("WAIT_SELLER_SEND_GOODS")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功，但卖家没有发货
				Date date=new Date();
				//定金支付成功后，订单号需要改变，不然支付尾款时，支付宝会报错，一个订单号不允许支付两次
				Long data=date.getTime()+yushouorder.getUser().getId();
				yushouorder.setCode(data.toString()+"11");
				yushouorder.setYstatus((short) 1);
				yushouMng.update(yushouorder);
				return  ShopFrontHelper.showMessage(request, model,"success");
			}else {
				return  ShopFrontHelper.showMessage(request, model,"success");
			}
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	/**
	 * 预售(尾款)支付宝返回参数
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "/aliReturnYushouWk.jspx")
	public String aliReturnYushouWk(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]: valueStr + values[i] + ",";
			}
			params.put(name, valueStr);
		}
		//商户预售订单编号
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
		Payment payment =paymentMng.findByCode("alipayPartner");
		//Long orderId=Long.parseLong(out_trade_no);
		ShopYushou yushouorder=yushouMng.findByCode(out_trade_no);
		if(verify(params,payment.getPartner(),payment.getSellerKey())){
			if(trade_status.equals("WAIT_BUYER_PAY")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录，但没有付款
				return  ShopFrontHelper.showMessage(request, model,"尾款付款失败！");
			}else if(trade_status.equals("WAIT_SELLER_SEND_GOODS")){
				//该判断表示买家已在支付宝交易管理中产生了交易记录且付款成功，但卖家没有发货
				//状态改为已付尾款（完成）
				yushouorder.setYstatus((short) 2);
				yushouMng.update(yushouorder);
				//这个预售商品订单生成订单表里面的订单
				Order order=manager.findByCode(out_trade_no);
				if(order==null){					
					yushouMng.createYushouOrder(yushouorder, request);
				}
				return  ShopFrontHelper.showMessage(request, model,"success");
			}else if(trade_status.equals("WAIT_BUYER_CONFIRM_GOODS")){
				//该判断表示卖家已经发了货，但买家还没有做确认收货的操作
				return  ShopFrontHelper.showMessage(request, model,"已发货，未确认收货！");
			}else if(trade_status.equals("TRADE_FINISHED")){
				//该判断表示买家已经确认收货，这笔交易完成
				return  ShopFrontHelper.showMessage(request, model,"交易完成！");
			}else {
				return  ShopFrontHelper.showMessage(request, model,"success");
			}
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	private String ordersPayalipay(Payment payment,Website web,ShopPaymentorder shopPermentorder,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1"; //必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/ordersPayaliReturn.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/ordersPayaliReturn.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单号
		String out_trade_no = shopPermentorder.getCode().toString();//商户网站订单系统中唯一订单编号，必填
		//订单名称
		String subject = shopPermentorder.getProductName();//必填
		//付款金额
		String price = String.valueOf(shopPermentorder.getTotal());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		//物流费用
		String logistics_fee = String.valueOf(shopPermentorder.getFreight());
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		//订单描述
		String body = "("+shopPermentorder.getId()+")";
		//商品展示地址
		String show_url ="http://"+web.getDomain()+"/";		
		
	    //收货人姓名
		String receive_name = shopPermentorder.getReceiveName();
		//收货人地址
		String receive_address = shopPermentorder.getReceiveAddress();
		//收货人邮编
		String receive_zip = shopPermentorder.getReceiveZip();
	    //收货人电话号码
		 String receive_phone = shopPermentorder.getReceivePhone();
		//收货人手机号码
		String receive_mobile = shopPermentorder.getReceiveMobile();
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_partner_trade_by_buyer");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("price", price);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("quantity", quantity);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);		
		sParaTemp.put("receive_name", receive_name);
		sParaTemp.put("receive_address", receive_address);
		sParaTemp.put("receive_zip", receive_zip);
		sParaTemp.put("receive_phone", receive_phone);
		sParaTemp.put("receive_mobile", receive_mobile);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");
		return sHtmlText;
	}
	
	private String alipay(Payment payment,Website web,Order order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1"; //必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturn.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturn.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单号
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一订单id，必填
		//订单名称
		String subject = order.getProductName();//必填
		//商品付款金额(不含邮费)
		String price = String.valueOf(order.getProductPrice());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		//物流费用
		String logistics_fee = String.valueOf(order.getFreight());
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		//订单描述
		String body = "("+order.getId()+")";
		//商品展示地址
		String show_url ="http://"+web.getDomain()+"/";		
		
	    //收货人姓名
		String receive_name = order.getReceiveName();
		//收货人地址
		String receive_address = order.getReceiveAddress();
		//收货人邮编
		String receive_zip = order.getReceiveZip();
	    //收货人电话号码
		 String receive_phone = order.getReceivePhone();
		//收货人手机号码
		String receive_mobile = order.getReceiveMobile();
			
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_partner_trade_by_buyer");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("price", price);
		sParaTemp.put("quantity", quantity);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		
		sParaTemp.put("receive_name", receive_name);
		sParaTemp.put("receive_address", receive_address);
		sParaTemp.put("receive_zip", receive_zip);
		sParaTemp.put("receive_phone", receive_phone);
		sParaTemp.put("receive_mobile", receive_mobile);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");
		return sHtmlText;
	}

	private String alipayYushou(Payment payment,Website web,ShopYushou order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1"; //必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturnYushou.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturnYushou.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户预售订单编号
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一预售订单id，必填
		//订单名称
		String subject = order.getProductid().getName();//必填
		//付款金额(定金)
		String price = String.valueOf(order.getProductid().getDingjin()*order.getCount());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		////////////////////////////////////////////////
		//物流费用
		String logistics_fee = String.valueOf("0");
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		/////////////////////////////////////////////////
		//订单描述(支付定金时不需要支付邮费，支付尾款时再支付邮费)
		String body = "("+order.getId()+")号预售商品暂时不需要支付邮费，支付尾款时再支付邮费";
		//商品展示地址
		String show_url ="http://"+web.getDomain()+"/";
		//收货人姓名
		String receive_name = order.getAddress().getUsername();
		//收货人地址
		String receive_address =  order.getAddress().getDetailaddress();
		//收货人邮编
		String receive_zip =  order.getAddress().getPostCode();
		//收货人电话号码
		String receive_phone =  order.getAddress().getPhone();
		//收货人手机号码
		String receive_mobile = order.getAddress().getTel();
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_partner_trade_by_buyer");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("price", price);
		sParaTemp.put("quantity", quantity);
		//////////////////////////////////////////////
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		////////////////////////////////////////////////
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("receive_name", receive_name);
		sParaTemp.put("receive_address", receive_address);
		sParaTemp.put("receive_zip", receive_zip);
		sParaTemp.put("receive_phone", receive_phone);
		sParaTemp.put("receive_mobile", receive_mobile);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");
		return sHtmlText;
	}
	
	private String alipayYushouWk(Payment payment,Website web,ShopYushou order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1"; //必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturnYushouWk.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturnYushouWk.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户预售订单编号
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一预售订单编号，必填
		//订单名称
		String subject = order.getProductid().getName();//必填
		//付款金额(尾款)
		String price = String.valueOf(order.getProductid().getWeikuan()*order.getCount());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		//物流费用
		String logistics_fee = String.valueOf(order.getFreight());
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		//订单描述
		String body = "("+order.getId()+")";
		//商品展示地址
		String show_url ="http://"+web.getDomain()+"/";
		//收货人姓名
		String receive_name = order.getAddress().getUsername();
		//收货人地址
		String receive_address =  order.getAddress().getDetailaddress();
		//收货人邮编
		String receive_zip =  order.getAddress().getPostCode();
		//收货人电话号码
		String receive_phone =  order.getAddress().getPhone();
		//收货人手机号码
		String receive_mobile = order.getAddress().getTel();
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_partner_trade_by_buyer");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("price", price);
		sParaTemp.put("quantity", quantity);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("receive_name", receive_name);
		sParaTemp.put("receive_address", receive_address);
		sParaTemp.put("receive_zip", receive_zip);
		sParaTemp.put("receive_phone", receive_phone);
		sParaTemp.put("receive_mobile", receive_mobile);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");
		return sHtmlText;
	}

	private String ordersPayalipayapi(Payment payment,Website web,ShopPaymentorder shopPermentorder,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1";//必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/ordersPayaliReturnUrl.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/ordersPayaliReturnUrl.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单编号
		String out_trade_no = shopPermentorder.getCode().toString();//商户网站订单系统中唯一订单id，必填
		//订单名称
		String subject = shopPermentorder.getProductName();//必填
		//付款金额
		String total_fee = String.valueOf(shopPermentorder.getTotal());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		//物流费用
		String logistics_fee = String.valueOf(shopPermentorder.getFreight());
		//订单描述
		String body = "("+shopPermentorder.getId()+")";
		//商品展示地址
		String show_url = "http://"+web.getDomain()+"/";
		//防钓鱼时间戳
		String anti_phishing_key = "";//若要使用请调用类文件submit中的query_timestamp函数
		//客户端的IP地址
		String exter_invoke_ip = RequestUtils.getIpAddr(request);//非局域网的外网IP地址，如：221.0.0.1
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_direct_pay_by_user");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("total_fee", total_fee);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("quantity", quantity);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("anti_phishing_key", anti_phishing_key);
		sParaTemp.put("exter_invoke_ip", exter_invoke_ip);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");	
		return sHtmlText;
	}
	
	//支付宝返回参数：多个订单提交付款时{加入购物车的形式最终付款})
	@RequestMapping(value = "/ordersPayaliReturnUrl.jspx")
	public String ordersPayaliReturndirect(long id,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		//获取支付宝POST过来反馈信息
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]
						: valueStr + values[i] + ",";
			}
			//乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
			//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
			params.put(name, valueStr);
		}
		//商户订单编号
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");

		Payment paymentPlugins =paymentMng.findByCode("alipay");
		
		//Long Id1=Long.parseLong(out_trade_no);
		ShopPaymentorder shopPermentorder=shopPermentOrderMng.findByCode(out_trade_no);
		if(verify(params,paymentPlugins.getPartner(),paymentPlugins.getSellerKey())){//验证成功
			if(trade_status.equals("TRADE_FINISHED")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
				
				//主订单改成“已支付”
				shopPermentorder.setStatus(2);
				shopPermentorder.setTradeno(trade_no);
				shopPermentOrderMng.update(shopPermentorder);
				List<Order> order= manager.getPaymentOrder(shopPermentorder);
				for(int i=0;i<order.size();i++){
					//副订单改成“已支付”
					order.get(i).setPaymentStatus(2);
					order.get(i).setTradeNo(trade_no);
					order.get(i).setPaymentCode("alipayPartner");
					manager.updateByUpdater(order.get(i));
				}
				return  ShopFrontHelper.showMessage(request, model,"付款成功，请等待发货！");
				//注意：
				//该种交易状态只在两种情况下出现
				//1、开通了普通即时到账，买家付款成功后。
				//2、开通了高级即时到账，从该笔交易成功时间算起，过了签约时的可退款时限（如：三个月以内可退款、一年以内可退款等）后。
			} else if (trade_status.equals("TRADE_SUCCESS")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
				//主订单改成“已支付”
				shopPermentorder.setStatus(2);
				shopPermentorder.setTradeno(trade_no);
				shopPermentOrderMng.update(shopPermentorder);
				List<Order> order= manager.getPaymentOrder(shopPermentorder);
				for(int i=0;i<order.size();i++){
					//副订单改成“已支付”
					order.get(i).setPaymentStatus(2);
					order.get(i).setTradeNo(trade_no);
					order.get(i).setPaymentCode("alipayPartner");
					manager.updateByUpdater(order.get(i));
				}
				return  ShopFrontHelper.showMessage(request, model,"付款成功，请等待发货！");
				//注意：
				//该种交易状态只在一种情况下出现——开通了高级即时到账，买家付款成功后。
			}
		}else{//验证失败
			return  ShopFrontHelper.showMessage(request, model,"验证失败！");
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	//支付宝返回参数
	@RequestMapping(value = "/aliReturnUrl.jspx")
	public String aliReturndirect(long id,HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		//获取支付宝POST过来反馈信息
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]
						: valueStr + values[i] + ",";
			}
			//乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
			//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
			params.put(name, valueStr);
		}
		//商户订单id
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");

		Payment paymentPlugins =paymentMng.findByCode("alipay");
		
		//Long Id1=Long.parseLong(out_trade_no);
		Order order=manager.findByCode(out_trade_no);
		if(verify(params,paymentPlugins.getPartner(),paymentPlugins.getSellerKey())){//验证成功
			if(trade_status.equals("TRADE_FINISHED")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
					
				order.setPaymentStatus(2);
				order.setTradeNo(trade_no);
				manager.updateByUpdater(order);
				return  ShopFrontHelper.showMessage(request, model,"付款成功，请等待发货！");
				//注意：
				//该种交易状态只在两种情况下出现
				//1、开通了普通即时到账，买家付款成功后。
				//2、开通了高级即时到账，从该笔交易成功时间算起，过了签约时的可退款时限（如：三个月以内可退款、一年以内可退款等）后。
			} else if (trade_status.equals("TRADE_SUCCESS")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
				order.setPaymentStatus(2);
				manager.updateByUpdater(order);
				return  ShopFrontHelper.showMessage(request, model,"付款成功，请等待发货！");
				//注意：
				//该种交易状态只在一种情况下出现——开通了高级即时到账，买家付款成功后。
			}
		}else{//验证失败
			return  ShopFrontHelper.showMessage(request, model,"验证失败！");
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	
	//支付宝返回参数
	@RequestMapping(value = "/aliReturnUrlYushou.jspx")
	public String aliReturndirectYushou(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		//获取支付宝POST过来反馈信息
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]
						: valueStr + values[i] + ",";
			}
			//乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
			//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
			params.put(name, valueStr);
		}
		//商户订单id
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");

		Payment paymentPlugins =paymentMng.findByCode("alipay");
		//Long orderId=Long.parseLong(out_trade_no);
		ShopYushou order=yushouMng.findByCode(out_trade_no);
		
		if(verify(params,paymentPlugins.getPartner(),paymentPlugins.getSellerKey())){//验证成功
			if(trade_status.equals("TRADE_FINISHED")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
					Date date=new Date();
					//定金支付成功后，订单号需要改变，不然支付尾款时，支付宝会报错，一个订单号不允许支付两次
					Long data=date.getTime()+order.getUser().getId();
					order.setCode(data.toString()+"11");
					order.setYstatus((short)1);
					yushouMng.update(order);
			
				
					return  ShopFrontHelper.showMessage(request, model,"定金支付成功，请支付尾款或等待支付尾款！");
				//注意：
				//该种交易状态只在两种情况下出现
				//1、开通了普通即时到账，买家付款成功后。
				//2、开通了高级即时到账，从该笔交易成功时间算起，过了签约时的可退款时限（如：三个月以内可退款、一年以内可退款等）后。
			} else if (trade_status.equals("TRADE_SUCCESS")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
				Date date=new Date();
				//定金支付成功后，订单号需要改变，不然支付尾款时，支付宝会报错，一个订单号不允许支付两次
				Long data=date.getTime()+order.getUser().getId();
				order.setCode(data.toString()+"11");
			    order.setYstatus((short)1);
				yushouMng.update(order);
				return  ShopFrontHelper.showMessage(request, model,"定金支付成功，请支付尾款或等待支付尾款！");
				//注意：
				//该种交易状态只在一种情况下出现——开通了高级即时到账，买家付款成功后。
			}
		}else{//验证失败
			return  ShopFrontHelper.showMessage(request, model,"验证失败！");
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}
	
	//111111111111111111111111111111111(此段代码正在修改当中)111111111111111111111111111111111111111111111111111
	//支付宝返回参数（预收尾款）
	@RequestMapping(value = "/aliReturnUrlYushouWk.jspx")
	public String aliReturnUrlYushouWk(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws UnsupportedEncodingException {
		//获取支付宝POST过来反馈信息
		Map<String,String> params = new HashMap<String,String>();
		Map requestParams = request.getParameterMap();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]
						: valueStr + values[i] + ",";
			}
			//乱码解决，这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
			//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
			params.put(name, valueStr);
		}
		//商户订单编号
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//支付宝交易号
		String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
		//交易状态
		String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");

		Payment paymentPlugins =paymentMng.findByCode("alipay");
		//Long orderId=Long.parseLong(out_trade_no);
		ShopYushou order=yushouMng.findByCode(out_trade_no);
		
		if(verify(params,paymentPlugins.getPartner(),paymentPlugins.getSellerKey())){//验证成功
			if(trade_status.equals("TRADE_FINISHED")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
					order.setYstatus((short)2);
					yushouMng.update(order);
					Order orderyu=manager.findByCode(out_trade_no);
					if(orderyu==null){					
						yushouMng.createYushouOrder(order, request);
					}
					return  ShopFrontHelper.showMessage(request, model,"尾款支付成功，请等待发货！");
				//注意：
				//该种交易状态只在两种情况下出现
				//1、开通了普通即时到账，买家付款成功后。
				//2、开通了高级即时到账，从该笔交易成功时间算起，过了签约时的可退款时限（如：三个月以内可退款、一年以内可退款等）后。
			} else if (trade_status.equals("TRADE_SUCCESS")){
				//判断该笔订单是否在商户网站中已经做过处理
				//如果没有做过处理，根据订单号（out_trade_no）在商户网站的订单系统中查到该笔订单的详细，并执行商户的业务程序
				//如果有做过处理，不执行商户的业务程序
			    order.setYstatus((short)2);
				yushouMng.update(order);
				Order orderyu=manager.findByCode(out_trade_no);
				if(orderyu==null){					
					yushouMng.createYushouOrder(order, request);
				}
				return  ShopFrontHelper.showMessage(request, model,"尾款支付成功，请等待发货！");
				//注意：
				//该种交易状态只在一种情况下出现——开通了高级即时到账，买家付款成功后。
			}
		}else{//验证失败
			return  ShopFrontHelper.showMessage(request, model,"验证失败！");
		}
		return  ShopFrontHelper.showMessage(request, model,"付款异常！");
	}

	private String alipayapi(Payment payment,Website web,Order order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1";//必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturnUrl.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturnUrl.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单编号
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一订单id，必填
		//订单名称
		String subject = order.getProductName();//必填
		//商品付款金额(不含邮费)
		String total_fee = String.valueOf(order.getProductPrice());//必填
		//商品数量
		String quantity = "1";//必填，建议默认为1，不改变值，把一次交易看成是一次下订单而非购买一件商品
		//物流费用
		String logistics_fee = String.valueOf(order.getFreight());
		//订单描述
		String body = "("+order.getId()+")";
		//商品展示地址
		String show_url = "http://"+web.getDomain()+"/";
		//防钓鱼时间戳
		String anti_phishing_key = "";//若要使用请调用类文件submit中的query_timestamp函数
		//客户端的IP地址
		String exter_invoke_ip = RequestUtils.getIpAddr(request);//非局域网的外网IP地址，如：221.0.0.1
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_direct_pay_by_user");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("total_fee", total_fee);	
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("quantity", quantity);	
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("anti_phishing_key", anti_phishing_key);
		sParaTemp.put("exter_invoke_ip", exter_invoke_ip);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");	
		return sHtmlText;
	}
	
	private String alipayapiYushouWk(Payment payment,Website web,ShopYushou order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1";//必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturnUrlYushouWk.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturnUrlYushouWk.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单id
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一订单id，必填
		//订单名称
		String subject = order.getProductid().getName();//必填
		//付款金额(尾款)
		String total_fee = String.valueOf(order.getProductid().getWeikuan()*order.getCount());//必填
		//物流费用
		String logistics_fee = String.valueOf(order.getFreight());
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		//订单描述
		String body = "("+order.getId()+")";
		//商品展示地址
		String show_url = "http://"+web.getDomain()+"/";
		//防钓鱼时间戳
		String anti_phishing_key = "";//若要使用请调用类文件submit中的query_timestamp函数
		//客户端的IP地址
		String exter_invoke_ip = RequestUtils.getIpAddr(request);//非局域网的外网IP地址，如：221.0.0.1
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_direct_pay_by_user");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("total_fee", total_fee);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("anti_phishing_key", anti_phishing_key);
		sParaTemp.put("exter_invoke_ip", exter_invoke_ip);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");	
		return sHtmlText;
	}
	
	private String alipayapiYushou(Payment payment,Website web,ShopYushou order,
			HttpServletRequest request,ModelMap model){
		//支付类型
		String payment_type = "1";//必填，不能修改
		//服务器异步通知页面路径
		String notify_url = "http://"+web.getDomain()+"/aliReturnUrlYushou.jspx";
		//页面跳转同步通知页面路径
		String return_url = "http://"+web.getDomain()+"/aliReturnUrlYushou.jspx";
		//卖家支付宝帐户
		String seller_email = payment.getSellerEmail();//必填
		//商户订单编号
		String out_trade_no = order.getCode().toString();//商户网站订单系统中唯一订单id，必填
		//订单名称
		String subject = order.getProductid().getName();//必填
		//付款金额
		String total_fee = String.valueOf(order.getProductid().getDingjin()*order.getCount());//必填
		//订单描述
		String body = "("+order.getId()+")号预售商品暂时不需要支付邮费，支付尾款时再支付邮费";
		//物流费用
		String logistics_fee = String.valueOf("0");
		//物流类型
		String logistics_type = "EXPRESS";//必填，三个值可选：EXPRESS（快递）、POST（平邮）、EMS（EMS）
		//物流支付方式
		String logistics_payment = "BUYER_PAY";//必填，两个值可选：SELLER_PAY（卖家承担运费）、BUYER_PAY（买家承担运费）
		//商品展示地址
		String show_url = "http://"+web.getDomain()+"/";
		//防钓鱼时间戳
		String anti_phishing_key = "";//若要使用请调用类文件submit中的query_timestamp函数
		//客户端的IP地址
		String exter_invoke_ip = RequestUtils.getIpAddr(request);//非局域网的外网IP地址，如：221.0.0.1
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "create_direct_pay_by_user");
        sParaTemp.put("partner", payment.getPartner());
        sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("payment_type", payment_type);
		sParaTemp.put("notify_url", notify_url);
		sParaTemp.put("return_url", return_url);
		sParaTemp.put("seller_email", seller_email);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("total_fee", total_fee);
		sParaTemp.put("logistics_fee", logistics_fee);
		sParaTemp.put("logistics_type", logistics_type);
		sParaTemp.put("logistics_payment", logistics_payment);
		sParaTemp.put("body", body);
		sParaTemp.put("show_url", show_url);
		sParaTemp.put("anti_phishing_key", anti_phishing_key);
		sParaTemp.put("exter_invoke_ip", exter_invoke_ip);
		//建立请求
		String sHtmlText = buildRequest(sParaTemp,payment.getSellerKey(),"get","确认");	
		return sHtmlText;
	}
	
	
	private String alipay(Payment payment,Order order,String waybill) throws Exception{
		////////////////////////////////////请求参数//////////////////////////////////////
		
		//支付宝交易号
		String trade_no = order.getTradeNo();
		//必填
		
		//物流公司名称
		String logistics_name = order.getShipping().getName();
		//必填
		
		//物流发货单号
		String invoice_no = waybill;
		//物流运输类型
		String transport_type = "EXPRESS";
		//三个值可选：POST（平邮）、EXPRESS（快递）、EMS（EMS）
		//////////////////////////////////////////////////////////////////////////////////
		//把请求参数打包成数组
		Map<String, String> sParaTemp = new HashMap<String, String>();
		sParaTemp.put("service", "send_goods_confirm_by_platform");
		sParaTemp.put("partner", payment.getPartner());
		sParaTemp.put("_input_charset", "utf-8");
		sParaTemp.put("trade_no", trade_no);
		sParaTemp.put("logistics_name", logistics_name);
		sParaTemp.put("invoice_no", invoice_no);
		sParaTemp.put("transport_type", transport_type);
		
		//建立请求
		String sHtmlText = buildRequest("", "", sParaTemp,payment.getSellerKey());
		return sHtmlText;
	}
///////////////////////////////////////////微信扫码支付//////////////////////////////////////////////////////////////////////////////////////////////
	//多个订单提交
	@RequestMapping(value="/WeChatScanCodePaymentReturn.jspx")
	public String WeChatScanCodePaymentReturn(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws JDOMException, IOException {
			//回调结果
			String xml_receive_result = getXmlRequest(request);
			System.out.println(xml_receive_result);
			Map<String, String> result_map = doXMLParse(xml_receive_result);
			String sign_receive=result_map.get("sign");
			result_map.remove("sign");
			String key=paymentMng.findByCode("weChatScancodePay").getSellerKey();
			if(key==null){
				return ShopFrontHelper.showMessage(request, model, "微信扫码支付密钥错误，请通知商户");
			}
			String checkSign=createSign(result_map,key);
			if(checkSign!=null&&checkSign.equals(sign_receive)){
				System.out.println("weixinhuidiaodizhi");
				try{
					//通知微信该订单已处理
					noticeWeChatSuccess();
					if(result_map!=null){
						String return_code=result_map.get("return_code");
						if("SUCCESS".equals(return_code)&&"SUCCESS".equals(result_map.get("result_code"))){
							System.out.println("11111111111111111111");
							String transaction_id=result_map.get("transaction_id");//微信返回的微信订单号（属于微信商户管理平台的订单号，跟自己的系统订单号不一样）
							String out_trade_no=result_map.get("out_trade_no"); //商户系统的订单号，与请求一致。
							ShopPaymentorder shopPermentorder=shopPermentOrderMng.findByCode(out_trade_no);
							//主订单改成“已支付”
							shopPermentorder.setStatus(2);
							//这里是把微信商户的订单号放入了交易号中
							shopPermentorder.setTradeno(transaction_id);
							shopPermentOrderMng.update(shopPermentorder);
							List<Order> order= manager.getPaymentOrder(shopPermentorder);
							System.out.println("222222222222222222222");
							for(int i=0;i<order.size();i++){
								//副订单改成“已支付”
								order.get(i).setPaymentStatus(2);
								order.get(i).setTradeNo(transaction_id);
								order.get(i).setPaymentCode("weChatScancodePay");
								manager.updateByUpdater(order.get(i));
							}
							System.out.println("3333333333333333333333");
							model.addAttribute("message","支付成功");
							//return "redirect:Return.jspx";
							//return showMessage(request,model,"支付成功");
							//request.getRequestDispatcher("Return.jspx").forward(request, response);
							//request.getRequestDispatcher("www.baidu.com").forward(request, response);
							return ShopFrontHelper.showMessage(request, model, "支付成功");
						}else if("SUCCESS".equals(return_code)&&result_map.get("err_code")!=null){
							return ShopFrontHelper.showMessage(request, model, result_map.get("err_code_des"));	
						}
					}
				}catch(Exception e){
					e.printStackTrace();
				}
			}else{
				Map<String,String> parames=new HashMap<String,String>();
				parames.put("return_code", "FAIL");
				parames.put("return_msg", "校验错误");
				//将参数转成xml格式
				String xmlWeChat = getRequestXml(parames);
				System.out.println("fasongweixinshibaishuju==="+xmlWeChat);
				try{    		
					testPost(UNIFORM_SINGLE_INTERFACE,xmlWeChat);
				}catch(Exception e){
					e.printStackTrace();
				}
				return ShopFrontHelper.showMessage(request, model, "支付参数错误，请重新支付!");
			}
        return ShopFrontHelper.showMessage(request, model, "支付错误，请重新支付!");	
	}
	
	@RequestMapping(value="/Return.jspx")
	public String showMessage(HttpServletRequest request,
			ModelMap model, String message) {
		Website web = SiteUtils.getWeb(request);
		ShopFrontHelper.setCommonData(request, model, web);
		model.put(MESSAGE, message);
		System.out.println("message=="+message);
		return web.getTplSys(COMMON_SYS, MessageResolver.getMessage(request,
				ShopFrontHelper.MESSAGE_PAGE), request);
	}
	
	//单个订单提交
	@RequestMapping(value="/WeChatScanCodePayReturn.jspx")
	public String WeChatScanCodePayReturn(HttpServletRequest request,HttpServletResponse response, ModelMap model) throws JDOMException, IOException {
		synchronized (this) {	
			//回调结果
			String xml_receive_result = getXmlRequest(request);
			System.out.println(xml_receive_result);
			Map<String, String> result_map = doXMLParse(xml_receive_result);
			String sign_receive=result_map.get("sign");
			result_map.remove("sign");
			String key=paymentMng.findByCode("weChatScancodePay").getSellerKey();
			if(key==null){
				return ShopFrontHelper.showMessage(request, model, "微信扫码支付密钥错误，请通知商户");
			}
			String checkSign=createSign(result_map,key);
			if(checkSign!=null&&checkSign.equals(sign_receive)){
				System.out.println("weixinhuidiaodizhi");
				try{
					//通知微信该订单已处理
					noticeWeChatSuccess();
					if(result_map!=null){
						String return_code=result_map.get("return_code");
						if("SUCCESS".equals(return_code)&&"SUCCESS".equals(result_map.get("result_code"))){
							System.out.println("11111111111111111111");
							String transaction_id=result_map.get("transaction_id");//微信返回的微信订单号（属于微信商户管理平台的订单号，跟自己的系统订单号不一样）
							String out_trade_no=result_map.get("out_trade_no"); //商户系统的订单号，与请求一致。
							Order order=manager.findByCode(out_trade_no);
							order.setPaymentStatus(2);
							order.setTradeNo(transaction_id);
							order.setPaymentCode("weChatScancodePay");
							manager.updateByUpdater(order);
							System.out.println("3333333333333333333333");
							return ShopFrontHelper.showMessage(request, model,"支付成功");
						}else if("SUCCESS".equals(return_code)&&result_map.get("err_code")!=null){
							return ShopFrontHelper.showMessage(request, model, result_map.get("err_code_des"));	
						}
					}
				}catch(Exception e){
					e.printStackTrace();
				}
			}else{
				Map<String,String> parames=new HashMap<String,String>();
				parames.put("return_code", "FAIL");
				parames.put("return_msg", "校验错误");
				//将参数转成xml格式
				String xmlWeChat = getRequestXml(parames);
				System.out.println("fasongweixinshibaishuju==="+xmlWeChat);
				try{    		
					testPost(UNIFORM_SINGLE_INTERFACE,xmlWeChat);
				}catch(Exception e){
					e.printStackTrace();
				}
				return ShopFrontHelper.showMessage(request, model, "支付参数错误，请重新支付!");
			}
		}
        return ShopFrontHelper.showMessage(request, model, "支付错误，请重新支付!");	
	}
	
	public String WeChatScanCodePay(Payment payment,Website web,Order order,
			HttpServletRequest request,HttpServletResponse 
			response,ModelMap model) throws JDOMException, IOException{
		String str = new String((order.getProductName()).getBytes(characterEncodingGBK),characterEncodingUTF8);
		Map<String,String> paramMap = new HashMap<String,String>();  
		paramMap.put("appid", payment.getPartner()); //微信分配的公众账号ID（企业号corpid即为此appId）[必填]
		paramMap.put("mch_id", payment.getSellerEmail()); //微信支付分配的商户号 [必填]
		paramMap.put("device_info", "WEB");//终端设备号(门店号或收银设备ID)，注意：PC网页或公众号内支付请传"WEB" [非必填]
		paramMap.put("nonce_str", getWCRandomNumber(10));  //随机字符串，不长于32位。  [必填]
		paramMap.put("body", str); //商品或支付单简要描述 [必填]
		paramMap.put("out_trade_no", order.getCode().toString()); //商户系统内部的订单号,32个字符内、可包含字母, [必填]
		paramMap.put("fee_type", "CNY"); //符合ISO 4217标准的三位字母代码，默认人民币：CNY. [非必填]
		paramMap.put("total_fee", fromYuanToFen(order.getTotal())); //金额必须为整数  单位为分 [必填]
		paramMap.put("spbill_create_ip",RequestUtils.getIpAddr(request)); //APP和网页支付提交用户端ip，Native支付填调用微信支付API的机器IP [必填]
		paramMap.put("notify_url", "http://"+web.getDomain()+"/WeChatScanCodePayReturn.jspx"); //接收微信支付异步通知回调地址，通知url必须为直接可访问的url，不能携带参数。 [必填]    
		paramMap.put("trade_type", "NATIVE"); //交易类型{取值如下：JSAPI，NATIVE，APP，(JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付)} [必填]
		paramMap.put("product_id", order.getId().toString()); // 商品ID{trade_type=NATIVE，此参数必传。此id为二维码中包含的商品ID，商户自行定义。}
		paramMap.put("sign",createSign(paramMap,payment.getSellerKey()));//根据微信签名规则，生成签名 
		String xmlWeChat = getRequestXml(paramMap);//把参数转换成XML数据格式   
		String resXml=testPost(UNIFORM_SINGLE_INTERFACE,xmlWeChat);
		System.out.println("resXml=="+resXml);
		Map<String, String> map = doXMLParse(resXml);
		String returnCode = map.get("return_code");
		if(returnCode.equalsIgnoreCase("FAIL")){
			return ShopFrontHelper.showMessage(request, model, map.get("return_msg"));
		}else if(returnCode.equalsIgnoreCase("SUCCESS")){
			if(map.get("err_code")!=null){
				return ShopFrontHelper.showMessage(request, model, map.get("err_code_des"));
			}else if(map.get("result_code").equalsIgnoreCase("SUCCESS")){				
				String code_url=map.get("code_url");
				getQRCode(code_url,response);
				return web.getTplSys(MEMBER_SYS, MessageResolver.getMessage(request,WECHATPAYMENT), request);
			}
		}
		return ShopFrontHelper.showMessage(request, model, "系统超时，请重试!");
	}
	
	@RequestMapping(value="/weChatPays.jspx")
	public String WeChatScanCodePayment(Long orderId,String code,
			HttpServletRequest request,HttpServletResponse response,ModelMap model) throws JDOMException, IOException{
		Website web = SiteUtils.getWeb(request);		
		if(orderId!=null&&shopPermentOrderMng.findById(orderId)!=null){
			ShopPaymentorder shopPermentorder=shopPermentOrderMng.findById(orderId);
			Payment payment=paymentMng.findByCode(code);			
			String str = new String((shopPermentorder.getProductName()).getBytes(characterEncodingUTF8),characterEncodingUTF8);
			Map<String,String> paramMap = new HashMap<String,String>();  
			paramMap.put("appid", payment.getPartner()); //微信分配的公众账号ID（企业号corpid即为此appId）[必填]
			paramMap.put("mch_id", payment.getSellerEmail()); //微信支付分配的商户号 [必填]
			paramMap.put("device_info", "WEB");//终端设备号(门店号或收银设备ID)，注意：PC网页或公众号内支付请传"WEB" [非必填]
			paramMap.put("nonce_str", getWCRandomNumber(10));  //随机字符串，不长于32位。  [必填]
			paramMap.put("body", str); //商品或支付单简要描述 [必填]
			paramMap.put("out_trade_no", shopPermentorder.getCode().toString()); //商户系统内部的订单号,32个字符内、可包含字母, [必填]
			paramMap.put("fee_type", "CNY"); //符合ISO 4217标准的三位字母代码，默认人民币：CNY. [非必填]
			paramMap.put("total_fee", fromYuanToFen(shopPermentorder.getTotal())); //金额必须为整数  单位为分 [必填]
			paramMap.put("spbill_create_ip",RequestUtils.getIpAddr(request)); //APP和网页支付提交用户端ip，Native支付填调用微信支付API的机器IP [必填]
			paramMap.put("notify_url", "http://"+web.getDomain()+"/WeChatScanCodePaymentReturn.jspx"); //接收微信支付异步通知回调地址，通知url必须为直接可访问的url，不能携带参数。 [必填]    
			paramMap.put("trade_type", "NATIVE"); //交易类型{取值如下：JSAPI，NATIVE，APP，(JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付)} [必填]
			paramMap.put("product_id", shopPermentorder.getId().toString()); // 商品ID{trade_type=NATIVE，此参数必传。此id为二维码中包含的商品ID，商户自行定义。}
			paramMap.put("sign",createSign(paramMap,payment.getSellerKey()));//根据微信签名规则，生成签名 
			String xmlWeChat = getRequestXml(paramMap);//把参数转换成XML数据格式   
			System.out.println("xmlWeChat=="+xmlWeChat);
			String resXml=testPost(UNIFORM_SINGLE_INTERFACE,xmlWeChat);
			System.out.println("resXml=="+resXml);
			Map<String, String> map = doXMLParse(resXml);
			String returnCode = map.get("return_code");
			if(returnCode.equalsIgnoreCase("FAIL")){
				return ShopFrontHelper.showMessage(request, model, map.get("return_msg"));
			}else if(returnCode.equalsIgnoreCase("SUCCESS")){
				if(map.get("err_code")!=null){
					return ShopFrontHelper.showMessage(request, model, map.get("err_code_des"));
				}else if(map.get("result_code").equalsIgnoreCase("SUCCESS")){				
					String code_url=map.get("code_url");
					getQRCode(code_url,response);
					return web.getTplSys(MEMBER_SYS, MessageResolver.getMessage(request,WECHATPAYMENT), request);
				}
			}
		}
		return ShopFrontHelper.showMessage(request, model, "系统超时，请重试!");	
	}
	
	@Autowired
	private OrderMng manager;
	@Autowired
	private PaymentMng paymentMng;
	@Autowired
	private ShipmentsMng shipmentMng;
	@Autowired
	private ShopYushouMng yushouMng;
	@Autowired
	private ShopPaymentorderMng shopPermentOrderMng;
	
}
